package com.burgstaller.provider;

import android.net.Uri;
import android.provider.BaseColumns;

/**
 * this class describes the data model for aGTD
 * @author rainer
 *
 */
public final class AGtd {
	
	public static final String LOG_TAG = "aGTD";
	public static final String SETTINGS_NAME = "agtd-settings";
	
    /**
     * The content:// style URL for the main application data
     */
    public static final Uri CONTENT_URI
    	= Uri.parse("content://com.burgstaller.provider.aGTD");

    public static final String AUTHORITY = "com.burgstaller.provider.aGTD";

	/**
	 * the Context table
	 * @author rainer
	 *
	 */
	public static class CommonColumns implements BaseColumns {
        /**
         * The default sort order for this table
         */
        public static final String DEFAULT_SORT_ORDER = "title ASC";
        
        /**
         * The title of the context
         * <P>Type: TEXT</P>
         */
        public static final String TITLE = "title";
        
        /**
         * description of the current task (if any).
         * <P>Type: TEXT</P>
         */
        public static final String NOTES = "notes";

        /**
         * The timestamp for when the task was created
         * <P>Type: INTEGER (long)</P>
         */
        public static final String CREATED_DATE = "created";

        /**
         * The timestamp for when the task was last modified
         * <P>Type: INTEGER (long)</P>
         */
        public static final String MODIFIED_DATE = "modified";

        /**
         * The timestamp for when the task was last synched.
         * <P>Type: INTEGER (long)</P>
         */
        public static final String SYNC_DATE = "last_synced";

        /**
         * The id which is used in an external system (app that 
         * aGTD synchronizes with.
         * <P>Type: INTEGER (long)</P>
         */
        public static final String EXTERNAL_ID = "external_id";

        // ==========================================
        // SYNCHRONIZATION
        // ==========================================
        /**
         * The synchronization status. 
         * <P>Type: INTEGER (long)</P>
         */
        public static final String SYNC_STATUS = "sync_status";

        /** The entry was created new in aGTD and should be 
         * uploaded to the external application.
         */
        public static final int SYNC_STATUS_NEW = 0;
        
        /** the entry was already synched and should be in sync
         * with the external application.
         */
        public static final int SYNC_STATUS_SYNCED = 1;
        
        /** the entry was removed in aGTD and should be 
         * removed from the external application.
         */
        public static final int SYNC_STATUS_DELETED = 2;
        
        /** this means that the entry is synched in general but
         * the user has made some modifications.
         */
        public static final int SYNC_STATUS_MODIFIED = 3;
	}

	/**
	 * the Context table
	 * @author rainer
	 *
	 */
	public static final class Contexts extends CommonColumns {
		public static String[] SAMPLE_DATA = { 
			"@Phone", "@Home", "@Office", "@Car" };

        /**
         * The content:// style URL for this table
         */
        public static final Uri CONTENT_URI
        	= Uri.parse("content://" + AUTHORITY + "/contexts");

        /** the record id of the inbox context. */
		public static final int INBOX_RECORD_ID = 0;
        
	}
	
	/**
	 * the projects table
	 * @author rainer
	 *
	 */
	public static final class Projects extends CommonColumns {
		public static String[] SAMPLE_DATA = { 
			"aGTD", "Home improvement", "purchase xmas presents"};

		/**
         * The content:// style URL for this table
         */
        public static final Uri CONTENT_URI
        	= Uri.parse("content://" + AUTHORITY + "/projects");
		
        /**
         * a boolean flag that marks a task as complete.
         * <P>Type: INTEGER (int)</P>
         */
        public static final String COMPLETED = "completed";
        
        /** the id of the parent project (for nested projects). */
        public static final String FK_PARENTPROJ_ID = "parentproj_id";
        
        /** the full path string which saves us from having
         * to look up all parents. 
         */
        public static final String PATH_NAME = "path_name";
	}
	
	/** 
	 * the tasks table
	 * @author rainer
	 *
	 */
	public static final class Tasks extends CommonColumns {
        /**
         * The content:// style URL for this table
         */
        public static final Uri CONTENT_URI
        	= Uri.parse("content://" + AUTHORITY + "/tasks");
        public static final Uri CONTENT_URI_FOR_CONTEXT
        	= Uri.parse("content://" + AUTHORITY + "/tasksForContext");
        public static final Uri CONTENT_URI_FOR_PROJECT
    		= Uri.parse("content://" + AUTHORITY + "/tasksForProject");

        /**
         * The foreign key of the context for which the task was created
         * <P>Type: INTEGER (int)</P>
         */
        public static final String FK_CONTEXT_ID = "context_id";

        /**
         * The foreign key of the context for which the task was created
         * <P>Type: INTEGER (int)</P>
         */
        public static final String FK_PROJECT_ID = "project_id";

        /**
         * The timestamp for when the context was created
         * <P>Type: INTEGER (long)</P>
         */
        public static final String START_DATE = "start";

        /**
         * The timestamp for when the context was created
         * <P>Type: INTEGER (long)</P>
         */
        public static final String DUE_DATE = "due";
        
        /**
         * a boolean flag that marks a task as complete.
         * <P>Type: INTEGER (int)</P>
         */
        public static final String COMPLETED = "completed";
        
        /** 
         * This column will store extra information used for synching
         * other clients (such as iGTD on the mac). 
         * <P>Type: TEXT</P>
         */
        public static final String EXTRA_SYNC_INFO = "extra_sync";
	}
	
	public static class Settings {
		public static final String LAST_SYNC_DATE = "last.sync.timestamp";
		public static final String IMAP_USER = "imap.user";
		public static final String IMAP_PASS = "imap.pass";
		public static final String IMAP_SERVER = "imap.server";
	}
	
}
